//
//  ClientViewController.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/2/25.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#import "ClientViewController.h"

#import "VisitingViewController.h"
#import "CallViewController.h"

#import "DCNavTabBarController.h"

#import "AddVisitiVC.h"
#import "AddPhoneVC.h"

@interface ClientViewController ()<UISearchBarDelegate,DCNavTabBarControllerDelegate>
{
    int x;//搜索框
    int y;//漏斗
    
    //全局view,好对其删除.
    UIView*view;
    //建两个全局的,来记录你点击了什么
    NSString *one;
    NSString *tow;
    NSString *thre;
    
    
    NSString *oneE;
    NSString *towE;
    NSString *threE;
    

}
@property(nonatomic,strong)UISearchBar * searchbar;
@property(nonatomic,strong)NSMutableDictionary *visitDic;
@property(nonatomic,strong)NSMutableDictionary *callDic;

@property (nonatomic,strong) NSString *rightBtnStr;

@end

@implementation ClientViewController

-(void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = NO;
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if (self.searchbar.text.length == 0) {
        [self.searchbar resignFirstResponder];
    }
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"客户管理";
    self.view.backgroundColor = BgColor;

    _visitDic = [NSMutableDictionary dictionary];
    _callDic = [NSMutableDictionary dictionary];

 //默认值
    x = 0;
    y = 55;


    VisitingViewController *visitingVC = [[VisitingViewController alloc] init];
    visitingVC.title = @"来访客户管理";
    
    CallViewController *callVC = [[CallViewController alloc] init];
    callVC.title = @"来电客户管理";
    NSArray *subViewControllers = @[visitingVC,callVC];

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, LL_StatusBarAndNavigationBarHeight, B_WIDTH, 1)];
    [self.view addSubview:view];

    DCNavTabBarController *tabBarVC = [[DCNavTabBarController alloc]initWithSubViewControllers:subViewControllers];
    tabBarVC.delegate = self;
    tabBarVC.view.frame = CGRectMake(0, LL_StatusBarAndNavigationBarHeight+44, B_WIDTH, B_HEIGHT - 44 - LL_StatusBarAndNavigationBarHeight);
    [self.view addSubview:tabBarVC.view];
    [self addChildViewController:tabBarVC];

    UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:nil style:UIBarButtonItemStylePlain target:self action:@selector(changeRightBtnClick)];
    
    self.navigationItem.rightBarButtonItem = rightBarItem;
    [self.navigationItem.rightBarButtonItem setImage:[[UIImage imageNamed:@"noLike"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

    [self setUpSearchBar];
}

-(void)didBtnTah:(UIButton *)btnTag
{

    if (btnTag.tag == 10000)
    {
        self.rightBtnStr = @"来访客户管理";
        x = 0;
        y = 55;
 
    }
    
    if (btnTag.tag ==10001)
    {
        self.rightBtnStr = @"来电客户管理";

        x = 1;
        y = 56;
        
    }
    
    
}
-(void)setUpSearchBar
{
    UIView *aVIew = [[UIView alloc] initWithFrame:CGRectMake(0, LL_StatusBarAndNavigationBarHeight, B_WIDTH, 44)];
    aVIew.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:aVIew];
    _searchbar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, B_WIDTH-60, 44)];
    _searchbar.delegate = self;
    _searchbar.backgroundColor = [UIColor orangeColor];
    _searchbar.backgroundImage = [self imageWithColor:[UIColor clearColor] size:_searchbar.bounds.size];
    [_searchbar setPlaceholder:@"输入搜索内容"];
    [aVIew addSubview:_searchbar];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(B_WIDTH-40, LL_StatusBarAndNavigationBarHeight+7, 20, 30);
    [btn setBackgroundImage:[UIImage imageNamed:@"Btn_seacher"] forState:0];
    [btn addTarget:self action:@selector(changeKuangBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}

//取消searchbar背景色
- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
{
    CGRect rect = CGRectMake(0, 0, size.width, size.height);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}
-(void)changeRightBtnClick
{
    if (_rightBtnStr)
    {
        if ([_rightBtnStr isEqualToString:@"来电客户管理"])
        {
            AddPhoneVC *phoneVC = [[AddPhoneVC alloc] init];
            [self.navigationController pushViewController:phoneVC animated:NO];
        }
        else if ([_rightBtnStr isEqualToString:@"来访客户管理"])
        {
            AddVisitiVC *addVc = [[AddVisitiVC alloc] init];
         [self.navigationController pushViewController:addVc animated:YES];
            

        }
        
    }
    else
    {
        
        
        AddVisitiVC *addVc = [[AddVisitiVC alloc] init];

        [self.navigationController pushViewController:addVc animated:YES];
    }

    
}

#pragma mark- 搜索的方法
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    if (searchBar.text.length==0) {
        return;
    }
    if (x==0)
    {
        //搜索的第一个
        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
        [center postNotificationName:@"Visi" object:searchBar.text userInfo:nil];
    }else
    {
        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
        [center postNotificationName:@"Call" object:searchBar.text userInfo:nil];
    }
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
    if (searchText.length == 0) {
        if (x==0) {
            NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
            [center postNotificationName:@"VisiClear" object:nil userInfo:nil];
        }else {
            NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
            [center postNotificationName:@"CallClear" object:nil userInfo:nil];
        }
        
    }
}
-(void)changeKuangBtnClick:(UIButton *)btn
{
    if (y == 55)
    {
        [self visitingXuanBtnClick];
    }
    else
    {
        [self cellXuanBtnClick];
    }
}

#pragma mark--来访客户漏斗搜索
-(void)visitingXuanBtnClick
{
    view=[[UIView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 260)];
    view.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:view];
    
    UILabel *typeLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, 100, 20)];
    typeLab.font = [UIFont systemFontOfSize:12];
    typeLab.text = @"客户等级";
    [view addSubview:typeLab];
    
    //线
    for (int i = 0; i<3; i++)
    {
        UILabel *linLab = [[UILabel alloc] init];
        linLab.frame = CGRectMake(0, 62+63*i, B_WIDTH, 0.5);
        linLab.backgroundColor = [UIColor grayColor];
        [view addSubview:linLab];
    }
    NSArray *titArr= @[@"A",@"B",@"C",@"D"];
    int AA = (B_WIDTH-10*5)/4;
    for (int m = 0; m <titArr.count; m++)
    {
        UIButton *chengBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        chengBtn.frame = CGRectMake(10+10*m+AA*m, 35, AA, 20);
        chengBtn.layer.cornerRadius = 2;
        chengBtn.layer.borderWidth = 1;
        chengBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [chengBtn setTitleColor:[UIColor blackColor] forState:0];
        chengBtn.layer.borderColor = [UIColor grayColor].CGColor;
        chengBtn.tag = 1000+m;
        [chengBtn addTarget:self action:@selector(visitABtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [chengBtn setTitle:titArr[m] forState:UIControlStateNormal];
        [view addSubview:chengBtn];
        
    }
    
    UILabel *tuiLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 70, 100, 20)];
    tuiLab.font = [UIFont systemFontOfSize:12];
    tuiLab.text = @"成交状态";
    [view addSubview:tuiLab];
    
    NSArray *titArr1= @[@"暂未成交",@"完成认筹",@"完成认购",@"完成签约"];
    for (int n = 0; n <titArr1.count; n++)
    {
        UIButton *tuiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        tuiBtn.frame = CGRectMake(10+10*n+AA*n, 95, AA, 20);
        tuiBtn.layer.cornerRadius = 2;
        tuiBtn.layer.borderWidth = 1;
        tuiBtn.titleLabel.font = [UIFont systemFontOfSize:10];
        [tuiBtn setTitleColor:[UIColor blackColor] forState:0];
        tuiBtn.layer.borderColor = [UIColor grayColor].CGColor;
        tuiBtn.tag = 1004+n;
        [tuiBtn addTarget:self action:@selector(visitABtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [tuiBtn setTitle:titArr1[n] forState:UIControlStateNormal];
        [view addSubview:tuiBtn];
        
    }
    
    //排列顺序
    UILabel *paiLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 132, 100, 20)];
    paiLab.font = [UIFont systemFontOfSize:12];
    paiLab.text = @"排列顺序";
    [view addSubview:paiLab];
    int BB = (B_WIDTH-10*3)/2;
    NSArray *titArr2= @[@"以来访日期排列",@"以跟进日期排列"];
    for (int p = 0; p <titArr2.count; p++)
    {
        UIButton *tuiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        tuiBtn.frame = CGRectMake(10+10*p+BB*p, 160, BB, 20);
        tuiBtn.layer.cornerRadius = 2;
        tuiBtn.layer.borderWidth = 1;
        tuiBtn.titleLabel.font = [UIFont systemFontOfSize:10];
        [tuiBtn setTitleColor:[UIColor blackColor] forState:0];
        tuiBtn.layer.borderColor = [UIColor grayColor].CGColor;
        tuiBtn.tag = 1008+p;
        [tuiBtn addTarget:self action:@selector(visitABtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [tuiBtn setTitle:titArr2[p] forState:UIControlStateNormal];
        [view addSubview:tuiBtn];
        
    }

    //确定按钮
    
    UIButton*determineBtn=[[UIButton alloc]initWithFrame:CGRectMake(10, 205, B_WIDTH-10*2, 35)];
    determineBtn.layer.cornerRadius = 5;
    [determineBtn setTitle:@"确定" forState:UIControlStateNormal];
    [determineBtn addTarget:self action:@selector(viSureBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    determineBtn.backgroundColor=[UIColor orangeColor];
    [view addSubview:determineBtn];
    
}
//四个按钮的点击事件,用来记录点击了什么
-(void)visitABtnClick:(UIButton*)btn
{
    UIButton*btn1=[self.view viewWithTag:1000];
    UIButton*btn2=[self.view viewWithTag:1001];
    UIButton*btn3=[self.view viewWithTag:1002];
    UIButton*btn4=[self.view viewWithTag:1003];
    UIButton*btn5=[self.view viewWithTag:1004];
    UIButton*btn6=[self.view viewWithTag:1005];
    UIButton*btn7=[self.view viewWithTag:1006];
    UIButton*btn8=[self.view viewWithTag:1007];
    UIButton*btn9=[self.view viewWithTag:1008];
    UIButton*btn10=[self.view viewWithTag:1009];
  
    if (btn.tag==1000) {
        //点击了一排第一个
        one=@"1";
        btn1.backgroundColor=[UIColor orangeColor];
        btn2.backgroundColor=[UIColor whiteColor];
        btn3.backgroundColor = [UIColor whiteColor];
        btn4.backgroundColor = [UIColor whiteColor];
    }else if (btn.tag==1001)
    { //点击了一排第二个
        one= @"2";
        btn2.backgroundColor=[UIColor orangeColor];
        btn1.backgroundColor=[UIColor whiteColor];
        btn3.backgroundColor = [UIColor whiteColor];
        btn4.backgroundColor = [UIColor whiteColor];
        
    }else if (btn.tag==1002)
    {
        one= @"3";
        btn3.backgroundColor=[UIColor orangeColor];
        btn1.backgroundColor=[UIColor whiteColor];
        btn2.backgroundColor=[UIColor whiteColor];
        btn4.backgroundColor = [UIColor whiteColor];
        
    }else if (btn.tag==1003)
    { //点击了二排第二个
        one= @"4";
        btn4.backgroundColor=[UIColor orangeColor];
        btn1.backgroundColor=[UIColor whiteColor];
        btn2.backgroundColor=[UIColor whiteColor];
        btn3.backgroundColor=[UIColor whiteColor];
    }
    else if (btn.tag == 1004)
    { //点击了二排第一个
       tow =@"1";
        btn5.backgroundColor = [UIColor orangeColor];
        btn6.backgroundColor=[UIColor whiteColor];
        btn7.backgroundColor=[UIColor whiteColor];
        btn8.backgroundColor=[UIColor whiteColor];
        
    }
    else if (btn.tag == 1005)
    {
        tow =@"2";
        btn6.backgroundColor = [UIColor orangeColor];
        btn5.backgroundColor=[UIColor whiteColor];
        btn7.backgroundColor=[UIColor whiteColor];
        btn8.backgroundColor=[UIColor whiteColor];
        
    }
    else if (btn.tag == 1006)
    {
        tow =@"3";
        btn7.backgroundColor = [UIColor orangeColor];
        btn6.backgroundColor=[UIColor whiteColor];
        btn5.backgroundColor=[UIColor whiteColor];
        btn8.backgroundColor=[UIColor whiteColor];
    }
    else if (btn.tag == 1007)
    {
        tow =@"4";
        btn8.backgroundColor = [UIColor orangeColor];
        btn6.backgroundColor=[UIColor whiteColor];
        btn7.backgroundColor=[UIColor whiteColor];
        btn5.backgroundColor=[UIColor whiteColor];
    }
    else if (btn.tag == 1008)
    {
        thre = @"1";
        btn9.backgroundColor = [UIColor orangeColor];
        btn10.backgroundColor=[UIColor whiteColor];
        
    }
    else if (btn.tag == 1009)
    {
        thre = @"2";
        btn10.backgroundColor = [UIColor orangeColor];
        btn9.backgroundColor=[UIColor whiteColor];
        

    }
    
}

//确定按钮的点击事件,用来掉接口
-(void)viSureBtnClick:(UIButton *)btn
{
    NSLog(@"走这一步了没有%@---%@",one,tow);
    if (one == nil)
    {
        
        [_visitDic setObject:@"" forKey:@"OO"];
       
        
    }
    else if (tow == nil)
    {
         [_visitDic setObject:@"" forKey:@"PP"];
    }
    else if (thre == nil)
    {
      [_visitDic setObject:@"" forKey:@"QQ"];
    }
    else
    {
        [_visitDic setObject:one forKey:@"OO"];
        [_visitDic setObject:tow forKey:@"PP"];
        [_visitDic setObject:thre forKey:@"QQ"];
    }
    
    //NSLog(@"%@",_fangArr);
    //点击后直接进行删除view
    [view removeFromSuperview];
    
    
    //最后让两个int归零,方便下次点击继续记录
    one=@"0" ;
    tow=@"0";
    thre = @"0";
    
    //TODO:第一步注册通知 来访漏斗
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center postNotificationName:@"VisitLouDou" object:_visitDic userInfo:nil];
}

#pragma mark--来电客户漏斗搜索
-(void)cellXuanBtnClick
{
    view=[[UIView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 260)];
    view.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:view];
    
    UILabel *typeLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, 100, 20)];
    typeLab.font = [UIFont systemFontOfSize:12];
    typeLab.text = @"客户等级";
    [view addSubview:typeLab];
    
    //线
    for (int i = 0; i<3; i++)
    {
        UILabel *linLab = [[UILabel alloc] init];
        linLab.frame = CGRectMake(0, 62+63*i, B_WIDTH, 0.5);
        linLab.backgroundColor = [UIColor grayColor];
        [view addSubview:linLab];
    }
    NSArray *titArr= @[@"A",@"B",@"C",@"D"];
    int AA = (B_WIDTH-10*5)/4;
    for (int m = 0; m <titArr.count; m++)
    {
        UIButton *chengBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        chengBtn.frame = CGRectMake(10+10*m+AA*m, 35, AA, 20);
        chengBtn.layer.cornerRadius = 2;
        chengBtn.layer.borderWidth = 1;
        chengBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [chengBtn setTitleColor:[UIColor blackColor] forState:0];
        chengBtn.layer.borderColor = [UIColor grayColor].CGColor;
        chengBtn.tag = 1000+m;
        [chengBtn addTarget:self action:@selector(cellABtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [chengBtn setTitle:titArr[m] forState:UIControlStateNormal];
        [view addSubview:chengBtn];
        
    }
    
    UILabel *tuiLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 70, 100, 20)];
    tuiLab.font = [UIFont systemFontOfSize:12];
    tuiLab.text = @"客户状态";
    [view addSubview:tuiLab];
    int CC = (B_WIDTH-10*4)/3;
    NSArray *titArr1= @[@"全部来电",@"未转来访",@"已转来访"];
    for (int n = 0; n <titArr1.count; n++)
    {
        UIButton *tuiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        tuiBtn.frame = CGRectMake(10+10*n+CC*n, 95, CC, 20);
        tuiBtn.layer.cornerRadius = 2;
        tuiBtn.layer.borderWidth = 1;
        tuiBtn.titleLabel.font = [UIFont systemFontOfSize:10];
        [tuiBtn setTitleColor:[UIColor blackColor] forState:0];
        tuiBtn.layer.borderColor = [UIColor grayColor].CGColor;
        tuiBtn.tag = 1004+n;
        [tuiBtn addTarget:self action:@selector(cellABtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [tuiBtn setTitle:titArr1[n] forState:UIControlStateNormal];
        [view addSubview:tuiBtn];
        
    }
    
    //排列顺序
    UILabel *paiLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 132, 100, 20)];
    paiLab.font = [UIFont systemFontOfSize:12];
    paiLab.text = @"排列顺序";
    [view addSubview:paiLab];
    int BB = (B_WIDTH-10*3)/2;
    NSArray *titArr2= @[@"以来电日期排列",@"以跟进日期排列"];
    for (int p = 0; p <titArr2.count; p++)
    {
        UIButton *tuiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        tuiBtn.frame = CGRectMake(10+10*p+BB*p, 160, BB, 20);
        tuiBtn.layer.cornerRadius = 2;
        tuiBtn.layer.borderWidth = 1;
        tuiBtn.titleLabel.font = [UIFont systemFontOfSize:10];
        [tuiBtn setTitleColor:[UIColor blackColor] forState:0];
        tuiBtn.layer.borderColor = [UIColor grayColor].CGColor;
        tuiBtn.tag = 1007+p;
        [tuiBtn addTarget:self action:@selector(cellABtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [tuiBtn setTitle:titArr2[p] forState:UIControlStateNormal];
        [view addSubview:tuiBtn];
        
    }
    
    //确定按钮
    
    UIButton*determineBtn=[[UIButton alloc]initWithFrame:CGRectMake(10, 205, B_WIDTH-10*2, 35)];
    determineBtn.layer.cornerRadius = 5;
    [determineBtn setTitle:@"确定" forState:UIControlStateNormal];
    [determineBtn addTarget:self action:@selector(cellSureBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    determineBtn.backgroundColor=[UIColor orangeColor];
    [view addSubview:determineBtn];
    
}
//四个按钮的点击事件,用来记录点击了什么
-(void)cellABtnClick:(UIButton*)btn
{
    UIButton*btn1=[self.view viewWithTag:1000];
    UIButton*btn2=[self.view viewWithTag:1001];
    UIButton*btn3=[self.view viewWithTag:1002];
    UIButton*btn4=[self.view viewWithTag:1003];
    UIButton*btn5=[self.view viewWithTag:1004];
    UIButton*btn6=[self.view viewWithTag:1005];
    UIButton*btn7=[self.view viewWithTag:1006];
    UIButton*btn8=[self.view viewWithTag:1007];
    UIButton*btn9=[self.view viewWithTag:1008];

    
    if (btn.tag==1000) {
        //点击了一排第一个
        one=@"1";
        btn1.backgroundColor=[UIColor orangeColor];
        btn2.backgroundColor=[UIColor whiteColor];
        btn3.backgroundColor = [UIColor whiteColor];
        btn4.backgroundColor = [UIColor whiteColor];
    }else if (btn.tag==1001)
    { //点击了一排第二个
        one= @"2";
        btn2.backgroundColor=[UIColor orangeColor];
        btn1.backgroundColor=[UIColor whiteColor];
        btn3.backgroundColor = [UIColor whiteColor];
        btn4.backgroundColor = [UIColor whiteColor];
        
    }else if (btn.tag==1002)
    {
        one= @"3";
        btn3.backgroundColor=[UIColor orangeColor];
        btn1.backgroundColor=[UIColor whiteColor];
        btn2.backgroundColor=[UIColor whiteColor];
        btn4.backgroundColor = [UIColor whiteColor];
        
    }else if (btn.tag==1003)
    {
        one= @"4";
        btn4.backgroundColor=[UIColor orangeColor];
        btn1.backgroundColor=[UIColor whiteColor];
        btn2.backgroundColor=[UIColor whiteColor];
        btn3.backgroundColor=[UIColor whiteColor];
    }
    else if (btn.tag == 1004)
    { //点击了二排第一个
        tow =@"3";
        btn5.backgroundColor = [UIColor orangeColor];
        btn6.backgroundColor=[UIColor whiteColor];
        btn7.backgroundColor=[UIColor whiteColor];
       
        
    }
    else if (btn.tag == 1005)
    {
        tow =@"2";
        btn6.backgroundColor = [UIColor orangeColor];
        btn5.backgroundColor=[UIColor whiteColor];
        btn7.backgroundColor=[UIColor whiteColor];
       
        
    }
    else if (btn.tag == 1006)
    {
        tow =@"1";
        btn7.backgroundColor = [UIColor orangeColor];
        btn6.backgroundColor=[UIColor whiteColor];
        btn5.backgroundColor=[UIColor whiteColor];
      
    }
    else if (btn.tag == 1007)
    {
        thre =@"1";
        btn8.backgroundColor = [UIColor orangeColor];
        btn9.backgroundColor=[UIColor whiteColor];
     
    }
    else if (btn.tag == 1008)
    {
        thre = @"2";
        btn9.backgroundColor = [UIColor orangeColor];
        btn8.backgroundColor=[UIColor whiteColor];
        
    }
   
    
}

//确定按钮的点击事件,用来掉接口
-(void)cellSureBtnClick:(UIButton *)btn
{
    NSLog(@"走这一步了没有%@---%@",one,tow);
    if (one == nil)
    {
        
        [_callDic setObject:@"" forKey:@"XX"];
        
        
    }
    else if (tow == nil)
    {
        [_callDic setObject:@"" forKey:@"YY"];
    }
    else if (thre == nil)
    {
        [_callDic setObject:@"" forKey:@"ZZ"];
    }
       else
    {
        [_callDic setObject:one forKey:@"XX"];
        [_callDic setObject:tow forKey:@"YY"];
        [_callDic setObject:thre forKey:@"ZZ"];
    }
    
 
    //点击后直接进行删除view
    [view removeFromSuperview];
    
    
    //最后让两个int归零,方便下次点击继续记录
    one=@"0" ;
    tow=@"0";
    thre = @"0";

    NSLog(@"走这一步了没有%@",one);
    //点击后直接进行删除view
    [view removeFromSuperview];
    //然后调接口
    
    //TODO:第一步注册通知 来电漏斗
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center postNotificationName:@"CellLouDou" object:_callDic userInfo:nil];
  
}

#pragma mark- 关闭键盘
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [_searchbar resignFirstResponder];
    
    return YES;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [_searchbar resignFirstResponder];
      [view removeFromSuperview];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
